# -*- coding: utf-8 -*-
import socketserver
import hashlib

user = {'jack':{'code':'1123',},
        'lily':{'code':'1134',},
        }

def user_md5(code, name):
    md5 = hashlib.md5(code.encode('utf-8'))
    md5.update(name.encode('utf-8'))
    return md5.digest()

def transfor():
    pass



class Myserver(socketserver.BaseRequestHandler):
    def handle(self):
        name = self.request.recv(1024).decode('utf-8')
        umd5 = self.request.recv(1024).decode('utf-8')
        if name in user:
            smd5 = user_md5(user[name]['code'])
            if umd5 == smd5:
                transfor()
            
            
            

def main():
    server = socketserver.ThreadingTCPServer(('127.0.0.1', 9001), Myserver)
    server.serve_forever()



if __name__ == '__main__':
    main()